﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows.Forms.DataVisualization;
using Microsoft.Win32;
using System.Runtime.InteropServices;

namespace EasyTrader
{
    using SysmanList = List<EasyTrader.Manager.SysManager>;
    delegate void DataFetcher();


    public partial class MainFrm : System.Windows.Forms.Form
    {
#region MemberVariables
        bool m_DataSaved = false;
        // 주문 관리자 생성
        private EasyTrader.Order.OrderManager m_OrderManager = new EasyTrader.Order.OrderManager();
        // 데이터 관리 객체 생성
        ETDataSet m_ObjectETDataSet = new ETDataSet("EasyTraderDataSet");
        EasyTrader.DataSet.DownloadCenter m_DownCenter = null;
        // 통합 신호 관리자 생성
        EasyTrader.Signal.TotalSignalManager m_GSignalManager = new EasyTrader.Signal.TotalSignalManager();
        public static EasyTrader.Form.DashboardFrm m_DashBoard = null;
        EasyTrader.Form.OperationSettings m_OperationSettingFrm = null;
        EasyTrader.Form.SignalSettings m_SignalSettingFrm = null;
        EasyTrader.Form.OrderSettings m_OrderSettingFrm = null;
        EasyTrader.Form.WaveSettings m_WaveSettingFrm = null;
        EasyTrader.Chart.SignalChartFrm m_SignalChartFrm = null;
        EasyTrader.Form.FutureSystemFrm m_SystemFrm = null;
        EasyTrader.Form.SimulationFrm m_SimulFrm = null;
        List<EasyTrader.Form.FutureSystemFrm> m_SystemFrmList = new List<EasyTrader.Form.FutureSystemFrm>();


        private DownloadManager m_ETDownloadManager = new DownloadManager();
        private DataFetcher[] m_ETDataFetcher = new DataFetcher[GlobalVar.FunctionNum];
        private string[] m_arrOpCode = new string[140];
        private string[] m_arrFCode = new string[8];
        private void InitDownloadManager()
        {
            ;
        }

#endregion
#region TimerVariable
        System.Timers.Timer SubTimer = new System.Timers.Timer();

        System.Diagnostics.Stopwatch MainStopWatch = new Stopwatch();
        System.Timers.Timer MainTimer = new System.Timers.Timer();
        
        delegate void TimerEventFiredDelegate();
        
        private TimerEventFiredDelegate DGMainTimer, DGSubTimer;
        IAsyncResult ARMainTimer, ARSubTimer;

        CPUTILLib.CpCybosClass m_CpCybos = new CPUTILLib.CpCybosClass();
        CPSYSDIBLib.WorldCurClass m_WorldCur = new CPSYSDIBLib.WorldCurClass();
#endregion
#region MemberFunctions

        
        // 타이머를 초기화 한다.
        private void InitMainTimer()
        {
            DGMainTimer = new MainFrm.TimerEventFiredDelegate(OnMainTimerWork);
            MainTimer.Interval = GlobalVar.MainTimerInterval;
            MainTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnMainTimerTick);
            //MainStopWatch.Start();
        }

        private void InitSubTimer()
        {
            DGSubTimer = new MainFrm.TimerEventFiredDelegate(OnSubTimerWork);
            SubTimer.Interval = GlobalVar.SubTimerInterval;
            SubTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnSubTimerTick);
            //MainStopWatch.Start();
        }



        private void OnSubTimerWork()
        {
            ;
        }

        private void OnSubTimerTick(object sender, EventArgs e)
        {
            ARSubTimer = BeginInvoke(DGSubTimer);
            //GlobalVar.CmeMstStarted = true;
        }

        private void OnMainTimerTick(object sender, EventArgs e)
        {
            ARMainTimer = BeginInvoke(DGMainTimer);
            //GlobalVar.CmeMstStarted = true;
        }

        private void OnMainTimerWork()
        {
            if (GlobalVar.DownloadLock == true)
                return;
            txtCrossCount.Text = "교차개수 : " + m_GSignalManager.CrossCount.ToString();
            txtMainState.Text = "시스템 메세지 : " + GlobalVar.StateMessage;
            txtServerOrderMsg.Text = " 주문 서버 메세지 : " + GlobalVar.ServerOrderMsg;

            if (m_ObjectETDataSet != null)
            {
                m_GSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                m_GSignalManager.ETWaveSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                m_GSignalManager.ETHogaSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                m_GSignalManager.ETSubjectSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                m_GSignalManager.ETHighLowSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
            }

            if (GlobalVar.OperationMode == GlobalVar.OperationModeNormal)
            {
                // 데이터를 XML로 저장시킨다.
                DateTime now = DateTime.Now;
                
                if (GlobalVar.SaveEveryMinute == true)
                {
                    if (now.Minute == 0)
                    {
                        m_ObjectETDataSet.SaveTablesToXML();
                        m_OrderManager.SaveOrderTables();
                        m_DataSaved = true;
                    }
                }
                else
                {
                    // 주문 정보를 저장한다.
                    if (now.Second == 0)
                    {
                        m_OrderManager.SaveOrderTables();
                    }
                    if (m_DataSaved == false && now.Hour == GlobalVar.DayCloseHour && now.Minute == GlobalVar.DayCloseMin)
                    {
                        m_ObjectETDataSet.SaveTablesToXML();
                        //m_OrderManager.SaveOrderTables();
                        m_DataSaved = true;
                    }
                }
                
                if (m_ObjectETDataSet != null)
                {
                    //m_GSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                    //m_GSignalManager.ETWaveSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                    //m_GSignalManager.ETHogaSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                    //m_GSignalManager.ETSubjectSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                    //m_GSignalManager.ETHighLowSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
                    int dayIndex = GlobalVar.DayIndex();
                    m_GSignalManager.CurIndex = dayIndex;

                    // 가격 상태를 갱신한다.
                    m_GSignalManager.UpdateAllPriceState();
                    // 시스템의 상태를 갱신한다.
                    m_GSignalManager.UpdateSysState();

                    if (m_DashBoard != null)
                    {
                        // 여기서 상황판을 갱신해 준다.
                        m_DashBoard.GSignalManager = m_GSignalManager;
                    }

                    if (m_SignalChartFrm != null)
                    {
                        // 여기서 상황판을 갱신해 준다.
                        m_SignalChartFrm.GSignalManager = m_GSignalManager;
                    }
                }
            }
            else // 모의 운영 모드
            {
                if (m_DashBoard != null)
                {
                    // 여기서 상황판을 갱신해 준다.
                    m_DashBoard.GSignalManager = m_GSignalManager;
                }
            }
        }
       
#endregion
#region DownLoadObject
        // 주문 유틸
        CPTRADELib.CpTdUtilClass m_TdUtil = new CPTRADELib.CpTdUtilClass();
        // 체결 정보 수집 객체
        private DSCBO1Lib.CpFConclusionClass m_CpFConclusion = new DSCBO1Lib.CpFConclusionClass();
        // 실시간 선물 호가 수집 객체
        private CPSYSDIBLib.FutureJpBidClass m_FutureJpBid = new CPSYSDIBLib.FutureJpBidClass();
        // 실시간 선물 현재가 수집 객체
        private DSCBO1Lib.FutureCurOnlyClass m_FutureCurOnly = new DSCBO1Lib.FutureCurOnlyClass();
        // 실시간 주체별 거래량 수집 객체
        private CPSYSDIBLib.CpSvrNew7221SClass m_CPSvrNew7221S = new CPSYSDIBLib.CpSvrNew7221SClass();
        // 실시간 프로그램 거래량 수집 객체
        private DSCBO1Lib.CpSvr8111SClass m_CpSvr8111S = new DSCBO1Lib.CpSvr8111SClass();
        // 실시간 야간선물 현재가 수집 객체
        private CPSYSDIBLib.CmeCurrClass m_CmeCur = new CPSYSDIBLib.CmeCurrClass();
      // 종목 코드 객체
        CPUTILLib.CpFutureCode m_CpFutureCode = new CPUTILLib.CpFutureCode();
        CPUTILLib.CpOptionCode m_CPOptionCode = new CPUTILLib.CpOptionCode();
#endregion
#region Server Object Event Handler

#endregion
#region MenuEventHandler
        private void 선물차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new FutOptChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();

        }

        private void 선물현재가차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.FutureCurOnlyChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 신호설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.SignalSettings();
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 계단식ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.Cascade);
        }

        private void 수평정렬ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void 수직정렬ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileVertical);
        }

        private void 아이콘정렬ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.ArrangeIcons);
        }

#endregion
        public MainFrm()
        {
            InitializeComponent();
            InitGlobal();
            DateTime now = DateTime.Now;
            if (now.Year == GlobalVar.YearLimit && now.Month >= GlobalVar.MonthLimit)
            {
                string msg = GlobalVar.CopyWriteMsg + "\n" + GlobalVar.Name + "\n" + GlobalVar.HP + "\n" + GlobalVar.EMail;
                System.Windows.Forms.MessageBox.Show(msg);
                this.Enabled = false;
                return;
            }
            m_GSignalManager.ETOrderManager = m_OrderManager;
            // 데이터 셋에 대한 참조를 넣어 준다.
            // 데이터 셋을 어디서든 참조할 수 있게 한다.
            GlobalVar.GDataSet = m_ObjectETDataSet;
            //m_GSignalManager.SignalChanged += new Signal.TotalSignalManager.SignalManagerEventHandler(On_SignalChaged);
            m_DownCenter = new EasyTrader.DataSet.DownloadCenter();
            m_ObjectETDataSet.DownLoader = m_DownCenter;
            m_DownCenter.EasyTraderDataSet = m_ObjectETDataSet;

            InitMainTimer();

            GlobalVar.GlobalSignalManager = m_GSignalManager;
            m_GSignalManager.EasyTraderDataSet = m_ObjectETDataSet;
            m_GSignalManager.InitHogaChartCtrl();
            m_GSignalManager.InitCallPutChartCtrl();

            m_ObjectETDataSet.DownLoader.ReadOpCross();
            // 시스템 목록을 만든다.
            m_GSignalManager.CreateSysManagerList(m_OrderManager);
            if (GlobalVar.OperationMode == GlobalVar.OperationModeNormal)
                m_DownCenter.StartTimer();
        }

        public void On_SignalChaged(object sender, EventArgs e)
        {
            ;
        }

        private void InitGlobal()
        {
            GlobalVar.FutureCode = m_CpFutureCode.GetData(0, 0);
            InitGlobalVariables();
        }

        private void InitSignalSource()
        {
            string regSubkey = "Software\\EasyTrader\\SignalSource";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("KospiForeignPersonEnable") as string;
            if (regStr == "True")
                GlobalVar.KospiForeignPersonEnable = true;
            else
                GlobalVar.KospiForeignPersonEnable = false;

            regStr = rk.GetValue("KospiOrganPersonEnable") as string;
            if (regStr == "True")
                GlobalVar.KospiOrganPersonEnable = true;
            else
                GlobalVar.KospiOrganPersonEnable = false;

            regStr = rk.GetValue("FutureForeignEnable") as string;
            if (regStr == "True")
                GlobalVar.FutureForeignEnable = true;
            else
                GlobalVar.FutureForeignEnable = false;

            regStr = rk.GetValue("OptionPersonCallPutEnable") as string;
            if (regStr == "True")
                GlobalVar.OptionPersonCallPutEnable = true;
            else
                GlobalVar.OptionPersonCallPutEnable = false;

            regStr = rk.GetValue("KospiProgramEnable") as string;
            if (regStr == "True")
                GlobalVar.KospiProgramEnable = true;
            else
                GlobalVar.KospiProgramEnable = false;

            regStr = rk.GetValue("HogaBuySellEnable") as string;
            if (regStr == "True")
                GlobalVar.HogaBuySellEnable = true;
            else
                GlobalVar.HogaBuySellEnable = false;

            regStr = rk.GetValue("HogaBidAskEnable") as string;
            if (regStr == "True")
                GlobalVar.HogaBidAskEnable = true;
            else
                GlobalVar.HogaBidAskEnable = false;

            regStr = rk.GetValue("WaveEnable") as string;
            if (regStr == "True")
                GlobalVar.WaveEnable = true;
            else
                GlobalVar.WaveEnable = false;

            regStr = rk.GetValue("ForecastEnable") as string;
            if (regStr == "True")
                GlobalVar.ForecastEnable = true;
            else
                GlobalVar.ForecastEnable = false;

            regStr = rk.GetValue("HighLowEnable") as string;
            if (regStr == "True")
                GlobalVar.HighLowEnable = true;
            else
                GlobalVar.HighLowEnable = false;

            regStr = rk.GetValue("WorldEnable") as string;
            if (regStr == "True")
                GlobalVar.WorldEnable = true;
            else
                GlobalVar.WorldEnable = false;

            regStr = rk.GetValue("DJIEnable") as string;
            if (regStr == "True")
                GlobalVar.DJIEnable = true;
            else
                GlobalVar.DJIEnable = false;

            regStr = rk.GetValue("NASDAQEnable") as string;
            if (regStr == "True")
                GlobalVar.NASDAQEnable = true;
            else
                GlobalVar.NASDAQEnable = false;

            regStr = rk.GetValue("SNP500Enable") as string;
            if (regStr == "True")
                GlobalVar.SNP500Enable = true;
            else
                GlobalVar.SNP500Enable = false;

            regStr = rk.GetValue("DAXEnable") as string;
            if (regStr == "True")
                GlobalVar.DAXEnable = true;
            else
                GlobalVar.DAXEnable = false;

            regStr = rk.GetValue("CACEnable") as string;
            if (regStr == "True")
                GlobalVar.CACEnable = true;
            else
                GlobalVar.CACEnable = false;

            regStr = rk.GetValue("FTSEEnable") as string;
            if (regStr == "True")
                GlobalVar.FTSEEnable = true;
            else
                GlobalVar.FTSEEnable = false;
        }

        private void InitGlobalVariables()
        {
            InitOperationGlobal();
            InitSignalGlobal();
            InitOrderGlobal();
            InitWaveGlobal();
            InitSignalSource();
            InitHogaSignalGlobal();
            //InitHogaJisuSysVar();
            InitFirstSignalSet();
            InitHogaSquareOccSet();
            //InitJisuSysVar();
            //InitHogaSysVar();
            //InitHogaSummitSysVar();
            //InitCallPutSysVar();
            //InitHogaSquareOccSysVar();
            InitOptionValSel();
            for (int i = 0; i < GlobalVar.SysNameArray.Length; i++)
            {
                InitSysVar(i);
            }
        }

        private void InitOptionValSel()
        {
            string regSubkey = "Software\\EasyTrader\\Option";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("OptValMonthLow") as string;
            if (regStr == "True")
                GlobalVar.OptValMonthLow = true;
            else
                GlobalVar.OptValMonthLow = false;

            regStr = rk.GetValue("OptValLowTarget") as string;
            if (regStr == "True")
                GlobalVar.OptValLowTarget = true;
            else
                GlobalVar.OptValLowTarget = false;

            regStr = rk.GetValue("OptValBase") as string;
            if (regStr == "True")
                GlobalVar.OptValBase = true;
            else
                GlobalVar.OptValBase = false;

            regStr = rk.GetValue("OptValHighTarget") as string;
            if (regStr == "True")
                GlobalVar.OptValHighTarget = true;
            else
                GlobalVar.OptValHighTarget = false;

            regStr = rk.GetValue("OptValMonthHigh") as string;
            if (regStr == "True")
                GlobalVar.OptValMonthHigh = true;
            else
                GlobalVar.OptValMonthHigh = false;
        }

        private void ClearAllAutoOrder()
        {
            for (int i = 0; i < GlobalVar.SysNameArray.Length; i++)
            {
                ClearAutoOrder(i);
            }
        }

        private void ClearAutoOrder(int a_SysType)
        {
            string selText = "False";
            bool autoOrder = false;

            string regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveHogaSummitSysVar";
            if (a_SysType == GlobalVar.SysTypeJisuWaveHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveHogaSummitSysVar";
                JisuWaveHogaSummitSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeJisuWave)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveSysVar";
                JisuWaveSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaWave)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaWaveSysVar";
                HogaWaveSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSquareOcc)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaSquareOccSysVar";
                HogaSquareOccSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaSummitSysVar";
                HogaSummitSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutSquareOcc)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\CallPutSquareOccSysVar";
                CallPutSquareOccSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypePureHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\PureHogaSummitSysVar";
                PureHogaSummitSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeLooseHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\LooseHogaSummitSysVar";
                LooseHogaSummitSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutInvDiv)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\CallPutInvDivSysVar";
                CallPutInvDivSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeTipAttack)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\TipAttackSysVar";
                TipAttackSysVar.AutoOrder = autoOrder;
            }
            else if (a_SysType == GlobalVar.SysTypeOptPrice)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptPriceSysVar";
                OptPriceSysVar.AutoOrder = autoOrder;
            }

            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            // 서브키 아래 값 쓰기
            rk.SetValue("AutoOrder", selText);
        }

        private void InitSysVar(int a_SysType)
        {
            int SysEndHour = 0;
            int SysEndMin = 0;
            int SysStartHour = 0;
            int SysStartMin = 0;

            bool AutoOrder = GlobalVar.AutoOrder;
            int OrderStartHour = GlobalVar.OrderStartHour;
            int OrderStartMin = GlobalVar.OrderStartMin;
            int OrderEndHour = GlobalVar.OrderEndHour;
            int OrderEndMin = GlobalVar.OrderEndMin;
            int OrderStartSignal = 1;
            int OrderEndSignal = 5;
            int PerOrderAmount = 1;


            bool EnableTotalProfitLiquid = false;
            bool EnableTotalLossLiquid = false;
            bool EnablePerProfitLiquid = false;
            bool EnablePerLossLiquid = false;
            double TotalProfitLiquidValue = 0.0;
            double TotalLossLiquidValue = 0.0;
            double PerProfitLiquidValue = 0.0;
            double PerLossLiquidValue = 0.0;

            int OrderTarget = GlobalVar.OrderTargetFuture;
            int FirstMaxOrderAmount = 3;

            string regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveHogaSummitSysVar";
            if (a_SysType == GlobalVar.SysTypeJisuWaveHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveHogaSummitSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeJisuWave)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\JisuWaveSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeHogaWave)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaWaveSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSquareOcc)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaSquareOccSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\HogaSummitSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutSquareOcc)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\CallPutSquareOccSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypePureHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\PureHogaSummitSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeLooseHogaSummit)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\LooseHogaSummitSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutInvDiv)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\CallPutInvDivSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeTipAttack)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\TipAttackSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeOptPrice)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptPriceSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeOptMainPrice)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptMainPriceSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeOptCenterPrice)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptCenterPriceSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeOptBothSell)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptBothSellSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeOptBend)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\OptBendSysVar";
            }
            else if (a_SysType == GlobalVar.SysTypeSubject)
            {
                regSubkey = "Software\\EasyTrader\\SysVar\\SubjectSysVar";
            }

            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("SysStartHour") as string;
            SysStartHour = Convert.ToInt32(regStr);
            regStr = rk.GetValue("SysStartMin") as string;
            SysStartMin = Convert.ToInt32(regStr);
            regStr = rk.GetValue("SysEndHour") as string;
            SysEndHour = Convert.ToInt32(regStr);
            regStr = rk.GetValue("SysEndMin") as string;
            SysEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            OrderStartHour = Convert.ToInt32(regStr);
            regStr = rk.GetValue("OrderStartMin") as string;
            OrderStartMin = Convert.ToInt32(regStr);
            regStr = rk.GetValue("OrderEndHour") as string;
            OrderEndHour = Convert.ToInt32(regStr);
            regStr = rk.GetValue("OrderEndMin") as string;
            OrderEndMin = Convert.ToInt32(regStr);
            regStr = rk.GetValue("OrderStartSignal") as string;
            OrderStartSignal = Convert.ToInt32(regStr);
            regStr = rk.GetValue("OrderEndSignal") as string;
            OrderEndSignal = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("TotalProfitLiquidValue") as string;
            TotalProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("TotalLossLiquidValue") as string;
            TotalLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("PerProfitLiquidValue") as string;
            PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("PerLossLiquidValue") as string;
            PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("AutoOrder") as string;
            if (regStr == "True")
                AutoOrder = true;
            else
                AutoOrder = false;

            regStr = rk.GetValue("EnableTotalLossLiquid") as string;
            if (regStr == "True")
                EnableTotalLossLiquid = true;
            else
                EnableTotalLossLiquid = false;

            regStr = rk.GetValue("EnableTotalProfitLiquid") as string;
            if (regStr == "True")
                EnableTotalProfitLiquid = true;
            else
                EnableTotalProfitLiquid = false;

            regStr = rk.GetValue("EnablePerLossLiquid") as string;
            if (regStr == "True")
                EnablePerLossLiquid = true;
            else
                EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnablePerProfitLiquid") as string;
            if (regStr == "True")
                EnablePerProfitLiquid = true;
            else
                EnablePerProfitLiquid = false;


            double StepLiquidVal = JisuWaveHogaSummitSysVar.StepLiquidVal;
            bool EnableTotalProfitStepLiquid = JisuWaveHogaSummitSysVar.EnableTotalProfitStepLiquid;
            int PerLiquidOrderAmount = JisuWaveHogaSummitSysVar.PerLiquidOrderAmount;


            bool EnableProfitTrailStop = JisuWaveHogaSummitSysVar.EnableProfitTrailStop;
            double MaxProfitLiquidVal = JisuWaveHogaSummitSysVar.MaxProfitLiquidVal;
            double MinProfit = JisuWaveHogaSummitSysVar.MinProfit;

            regStr = rk.GetValue("StepLiquidVal") as string;
            StepLiquidVal = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxProfitLiquidVal") as string;
            MaxProfitLiquidVal = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinProfit") as string;
            MinProfit = Convert.ToDouble(regStr);

            regStr = rk.GetValue("PerLiquidOrderAmount") as string;
            PerLiquidOrderAmount = Convert.ToInt32(regStr);


            regStr = rk.GetValue("EnableProfitTrailStop") as string;
            if (regStr == "True")
                EnableProfitTrailStop = true;
            else
                EnableProfitTrailStop = false;

            regStr = rk.GetValue("EnableTotalProfitStepLiquid") as string;
            if (regStr == "True")
                EnableTotalProfitStepLiquid = true;
            else
                EnableTotalProfitStepLiquid = false;


            regStr = rk.GetValue("OrderTarget") as string;
            if (regStr == "1")
                OrderTarget = GlobalVar.OrderTargetFuture;
            else
                OrderTarget = GlobalVar.OrderTargetOption;

            regStr = rk.GetValue("FirstMaxOrderAmount") as string;
            FirstMaxOrderAmount = Convert.ToInt32(regStr);
            // 여기서 시스템에 대하여 설정을 해준다.

            if (a_SysType == GlobalVar.SysTypeJisuWaveHogaSummit)
            {
                JisuWaveHogaSummitSysVar.SysStartHour = SysStartHour;
                JisuWaveHogaSummitSysVar.SysStartMin = SysStartMin;
                JisuWaveHogaSummitSysVar.SysEndHour = SysEndHour;
                JisuWaveHogaSummitSysVar.SysEndMin = SysEndMin;

                JisuWaveHogaSummitSysVar.OrderStartHour = OrderStartHour;
                JisuWaveHogaSummitSysVar.OrderStartMin = OrderStartMin;
                JisuWaveHogaSummitSysVar.OrderEndHour = OrderEndHour;
                JisuWaveHogaSummitSysVar.OrderEndMin = OrderEndMin;
                JisuWaveHogaSummitSysVar.SysStartState = OrderStartSignal;
                JisuWaveHogaSummitSysVar.SysEndState = OrderEndSignal;

                JisuWaveHogaSummitSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                JisuWaveHogaSummitSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                JisuWaveHogaSummitSysVar.PerLossLiquidValue = PerLossLiquidValue;
                JisuWaveHogaSummitSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                JisuWaveHogaSummitSysVar.AutoOrder = AutoOrder;
                JisuWaveHogaSummitSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                JisuWaveHogaSummitSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                JisuWaveHogaSummitSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                JisuWaveHogaSummitSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                JisuWaveHogaSummitSysVar.PerOrderAmount = PerOrderAmount;


                JisuWaveHogaSummitSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                JisuWaveHogaSummitSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                JisuWaveHogaSummitSysVar.StepLiquidVal = StepLiquidVal;
                JisuWaveHogaSummitSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                JisuWaveHogaSummitSysVar.MinProfit = MinProfit;
                JisuWaveHogaSummitSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                JisuWaveHogaSummitSysVar.OrderTarget = OrderTarget;
                JisuWaveHogaSummitSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeJisuWave)
            {
                JisuWaveSysVar.SysStartHour = SysStartHour;
                JisuWaveSysVar.SysStartMin = SysStartMin;
                JisuWaveSysVar.SysEndHour = SysEndHour;
                JisuWaveSysVar.SysEndMin = SysEndMin;

                JisuWaveSysVar.OrderStartHour = OrderStartHour;
                JisuWaveSysVar.OrderStartMin = OrderStartMin;
                JisuWaveSysVar.OrderEndHour = OrderEndHour;
                JisuWaveSysVar.OrderEndMin = OrderEndMin;
                JisuWaveSysVar.SysStartState = OrderStartSignal;
                JisuWaveSysVar.SysEndState = OrderEndSignal;

                JisuWaveSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                JisuWaveSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                JisuWaveSysVar.PerLossLiquidValue = PerLossLiquidValue;
                JisuWaveSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                JisuWaveSysVar.AutoOrder = AutoOrder;
                JisuWaveSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                JisuWaveSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                JisuWaveSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                JisuWaveSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                JisuWaveSysVar.PerOrderAmount = PerOrderAmount;

                JisuWaveSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                JisuWaveSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                JisuWaveSysVar.StepLiquidVal = StepLiquidVal;
                JisuWaveSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                JisuWaveSysVar.MinProfit = MinProfit;
                JisuWaveSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                JisuWaveSysVar.OrderTarget = OrderTarget;
                JisuWaveSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaWave)
            {
                HogaWaveSysVar.SysStartHour = SysStartHour;
                HogaWaveSysVar.SysStartMin = SysStartMin;
                HogaWaveSysVar.SysEndHour = SysEndHour;
                HogaWaveSysVar.SysEndMin = SysEndMin;

                HogaWaveSysVar.OrderStartHour = OrderStartHour;
                HogaWaveSysVar.OrderStartMin = OrderStartMin;
                HogaWaveSysVar.OrderEndHour = OrderEndHour;
                HogaWaveSysVar.OrderEndMin = OrderEndMin;
                HogaWaveSysVar.SysStartState = OrderStartSignal;
                HogaWaveSysVar.SysEndState = OrderEndSignal;

                HogaWaveSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                HogaWaveSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                HogaWaveSysVar.PerLossLiquidValue = PerLossLiquidValue;
                HogaWaveSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                HogaWaveSysVar.AutoOrder = AutoOrder;
                HogaWaveSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                HogaWaveSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                HogaWaveSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                HogaWaveSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                HogaWaveSysVar.PerOrderAmount = PerOrderAmount;

                HogaWaveSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                HogaWaveSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                HogaWaveSysVar.StepLiquidVal = StepLiquidVal;
                HogaWaveSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                HogaWaveSysVar.MinProfit = MinProfit;
                HogaWaveSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                HogaWaveSysVar.OrderTarget = OrderTarget;
                HogaWaveSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSquareOcc)
            {
                HogaSquareOccSysVar.SysStartHour = SysStartHour;
                HogaSquareOccSysVar.SysStartMin = SysStartMin;
                HogaSquareOccSysVar.SysEndHour = SysEndHour;
                HogaSquareOccSysVar.SysEndMin = SysEndMin;

                HogaSquareOccSysVar.OrderStartHour = OrderStartHour;
                HogaSquareOccSysVar.OrderStartMin = OrderStartMin;
                HogaSquareOccSysVar.OrderEndHour = OrderEndHour;
                HogaSquareOccSysVar.OrderEndMin = OrderEndMin;
                HogaSquareOccSysVar.SysStartState = OrderStartSignal;
                HogaSquareOccSysVar.SysEndState = OrderEndSignal;

                HogaSquareOccSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                HogaSquareOccSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                HogaSquareOccSysVar.PerLossLiquidValue = PerLossLiquidValue;
                HogaSquareOccSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                HogaSquareOccSysVar.AutoOrder = AutoOrder;
                HogaSquareOccSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                HogaSquareOccSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                HogaSquareOccSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                HogaSquareOccSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                HogaSquareOccSysVar.PerOrderAmount = PerOrderAmount;

                HogaSquareOccSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                HogaSquareOccSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                HogaSquareOccSysVar.StepLiquidVal = StepLiquidVal;
                HogaSquareOccSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                HogaSquareOccSysVar.MinProfit = MinProfit;
                HogaSquareOccSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                HogaSquareOccSysVar.OrderTarget = OrderTarget;
                HogaSquareOccSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeHogaSummit)
            {
                HogaSummitSysVar.SysStartHour = SysStartHour;
                HogaSummitSysVar.SysStartMin = SysStartMin;
                HogaSummitSysVar.SysEndHour = SysEndHour;
                HogaSummitSysVar.SysEndMin = SysEndMin;

                HogaSummitSysVar.OrderStartHour = OrderStartHour;
                HogaSummitSysVar.OrderStartMin = OrderStartMin;
                HogaSummitSysVar.OrderEndHour = OrderEndHour;
                HogaSummitSysVar.OrderEndMin = OrderEndMin;
                HogaSummitSysVar.SysStartState = OrderStartSignal;
                HogaSummitSysVar.SysEndState = OrderEndSignal;

                HogaSummitSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                HogaSummitSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                HogaSummitSysVar.PerLossLiquidValue = PerLossLiquidValue;
                HogaSummitSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                HogaSummitSysVar.AutoOrder = AutoOrder;
                HogaSummitSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                HogaSummitSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                HogaSummitSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                HogaSummitSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                HogaSummitSysVar.PerOrderAmount = PerOrderAmount;

                HogaSummitSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                HogaSummitSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                HogaSummitSysVar.StepLiquidVal = StepLiquidVal;
                HogaSummitSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                HogaSummitSysVar.MinProfit = MinProfit;
                HogaSummitSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                HogaSummitSysVar.OrderTarget = OrderTarget;
                HogaSummitSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutSquareOcc)
            {
                CallPutSquareOccSysVar.SysStartHour = SysStartHour;
                CallPutSquareOccSysVar.SysStartMin = SysStartMin;
                CallPutSquareOccSysVar.SysEndHour = SysEndHour;
                CallPutSquareOccSysVar.SysEndMin = SysEndMin;

                CallPutSquareOccSysVar.OrderStartHour = OrderStartHour;
                CallPutSquareOccSysVar.OrderStartMin = OrderStartMin;
                CallPutSquareOccSysVar.OrderEndHour = OrderEndHour;
                CallPutSquareOccSysVar.OrderEndMin = OrderEndMin;
                CallPutSquareOccSysVar.SysStartState = OrderStartSignal;
                CallPutSquareOccSysVar.SysEndState = OrderEndSignal;

                CallPutSquareOccSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                CallPutSquareOccSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                CallPutSquareOccSysVar.PerLossLiquidValue = PerLossLiquidValue;
                CallPutSquareOccSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                CallPutSquareOccSysVar.AutoOrder = AutoOrder;
                CallPutSquareOccSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                CallPutSquareOccSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                CallPutSquareOccSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                CallPutSquareOccSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                CallPutSquareOccSysVar.PerOrderAmount = PerOrderAmount;

                CallPutSquareOccSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                CallPutSquareOccSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                CallPutSquareOccSysVar.StepLiquidVal = StepLiquidVal;
                CallPutSquareOccSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                CallPutSquareOccSysVar.MinProfit = MinProfit;
                CallPutSquareOccSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;
                CallPutSquareOccSysVar.OrderTarget = OrderTarget;
                CallPutSquareOccSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypePureHogaSummit)
            {
                PureHogaSummitSysVar.SysStartHour = SysStartHour;
                PureHogaSummitSysVar.SysStartMin = SysStartMin;
                PureHogaSummitSysVar.SysEndHour = SysEndHour;
                PureHogaSummitSysVar.SysEndMin = SysEndMin;

                PureHogaSummitSysVar.OrderStartHour = OrderStartHour;
                PureHogaSummitSysVar.OrderStartMin = OrderStartMin;
                PureHogaSummitSysVar.OrderEndHour = OrderEndHour;
                PureHogaSummitSysVar.OrderEndMin = OrderEndMin;
                PureHogaSummitSysVar.SysStartState = OrderStartSignal;
                PureHogaSummitSysVar.SysEndState = OrderEndSignal;

                PureHogaSummitSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                PureHogaSummitSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                PureHogaSummitSysVar.PerLossLiquidValue = PerLossLiquidValue;
                PureHogaSummitSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                PureHogaSummitSysVar.AutoOrder = AutoOrder;
                PureHogaSummitSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                PureHogaSummitSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                PureHogaSummitSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                PureHogaSummitSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                PureHogaSummitSysVar.PerOrderAmount = PerOrderAmount;

                PureHogaSummitSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                PureHogaSummitSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                PureHogaSummitSysVar.StepLiquidVal = StepLiquidVal;
                PureHogaSummitSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                PureHogaSummitSysVar.MinProfit = MinProfit;
                PureHogaSummitSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;
                PureHogaSummitSysVar.OrderTarget = OrderTarget;
                PureHogaSummitSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeLooseHogaSummit)
            {
                LooseHogaSummitSysVar.SysStartHour = SysStartHour;
                LooseHogaSummitSysVar.SysStartMin = SysStartMin;
                LooseHogaSummitSysVar.SysEndHour = SysEndHour;
                LooseHogaSummitSysVar.SysEndMin = SysEndMin;

                LooseHogaSummitSysVar.OrderStartHour = OrderStartHour;
                LooseHogaSummitSysVar.OrderStartMin = OrderStartMin;
                LooseHogaSummitSysVar.OrderEndHour = OrderEndHour;
                LooseHogaSummitSysVar.OrderEndMin = OrderEndMin;
                LooseHogaSummitSysVar.SysStartState = OrderStartSignal;
                LooseHogaSummitSysVar.SysEndState = OrderEndSignal;

                LooseHogaSummitSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                LooseHogaSummitSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                LooseHogaSummitSysVar.PerLossLiquidValue = PerLossLiquidValue;
                LooseHogaSummitSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                LooseHogaSummitSysVar.AutoOrder = AutoOrder;
                LooseHogaSummitSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                LooseHogaSummitSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                LooseHogaSummitSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                LooseHogaSummitSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                LooseHogaSummitSysVar.PerOrderAmount = PerOrderAmount;

                LooseHogaSummitSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                LooseHogaSummitSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                LooseHogaSummitSysVar.StepLiquidVal = StepLiquidVal;
                LooseHogaSummitSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                LooseHogaSummitSysVar.MinProfit = MinProfit;
                LooseHogaSummitSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                LooseHogaSummitSysVar.OrderTarget = OrderTarget;
                LooseHogaSummitSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeCallPutInvDiv)
            {
                CallPutInvDivSysVar.SysStartHour = SysStartHour;
                CallPutInvDivSysVar.SysStartMin = SysStartMin;
                CallPutInvDivSysVar.SysEndHour = SysEndHour;
                CallPutInvDivSysVar.SysEndMin = SysEndMin;

                CallPutInvDivSysVar.OrderStartHour = OrderStartHour;
                CallPutInvDivSysVar.OrderStartMin = OrderStartMin;
                CallPutInvDivSysVar.OrderEndHour = OrderEndHour;
                CallPutInvDivSysVar.OrderEndMin = OrderEndMin;
                CallPutInvDivSysVar.SysStartState = OrderStartSignal;
                CallPutInvDivSysVar.SysEndState = OrderEndSignal;

                CallPutInvDivSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                CallPutInvDivSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                CallPutInvDivSysVar.PerLossLiquidValue = PerLossLiquidValue;
                CallPutInvDivSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                CallPutInvDivSysVar.AutoOrder = AutoOrder;
                CallPutInvDivSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                CallPutInvDivSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                CallPutInvDivSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                CallPutInvDivSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                CallPutInvDivSysVar.PerOrderAmount = PerOrderAmount;

                CallPutInvDivSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                CallPutInvDivSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                CallPutInvDivSysVar.StepLiquidVal = StepLiquidVal;
                CallPutInvDivSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                CallPutInvDivSysVar.MinProfit = MinProfit;
                CallPutInvDivSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                CallPutInvDivSysVar.OrderTarget = OrderTarget;
                CallPutInvDivSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeTipAttack)
            {
                TipAttackSysVar.SysStartHour = SysStartHour;
                TipAttackSysVar.SysStartMin = SysStartMin;
                TipAttackSysVar.SysEndHour = SysEndHour;
                TipAttackSysVar.SysEndMin = SysEndMin;

                TipAttackSysVar.OrderStartHour = OrderStartHour;
                TipAttackSysVar.OrderStartMin = OrderStartMin;
                TipAttackSysVar.OrderEndHour = OrderEndHour;
                TipAttackSysVar.OrderEndMin = OrderEndMin;
                TipAttackSysVar.SysStartState = OrderStartSignal;
                TipAttackSysVar.SysEndState = OrderEndSignal;

                TipAttackSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                TipAttackSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                TipAttackSysVar.PerLossLiquidValue = PerLossLiquidValue;
                TipAttackSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                TipAttackSysVar.AutoOrder = AutoOrder;
                TipAttackSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                TipAttackSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                TipAttackSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                TipAttackSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                TipAttackSysVar.PerOrderAmount = PerOrderAmount;

                TipAttackSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                TipAttackSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                TipAttackSysVar.StepLiquidVal = StepLiquidVal;
                TipAttackSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                TipAttackSysVar.MinProfit = MinProfit;
                TipAttackSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                TipAttackSysVar.OrderTarget = OrderTarget;
                TipAttackSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeOptPrice)
            {
                OptPriceSysVar.SysStartHour = SysStartHour;
                OptPriceSysVar.SysStartMin = SysStartMin;
                OptPriceSysVar.SysEndHour = SysEndHour;
                OptPriceSysVar.SysEndMin = SysEndMin;

                OptPriceSysVar.OrderStartHour = OrderStartHour;
                OptPriceSysVar.OrderStartMin = OrderStartMin;
                OptPriceSysVar.OrderEndHour = OrderEndHour;
                OptPriceSysVar.OrderEndMin = OrderEndMin;
                OptPriceSysVar.SysStartState = OrderStartSignal;
                OptPriceSysVar.SysEndState = OrderEndSignal;

                OptPriceSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                OptPriceSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                OptPriceSysVar.PerLossLiquidValue = PerLossLiquidValue;
                OptPriceSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                OptPriceSysVar.AutoOrder = AutoOrder;
                OptPriceSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                OptPriceSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                OptPriceSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                OptPriceSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                OptPriceSysVar.PerOrderAmount = PerOrderAmount;

                OptPriceSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                OptPriceSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                OptPriceSysVar.StepLiquidVal = StepLiquidVal;
                OptPriceSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                OptPriceSysVar.MinProfit = MinProfit;
                OptPriceSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                OptPriceSysVar.OrderTarget = OrderTarget;
                OptPriceSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeOptMainPrice)
            {
                OptMainPriceSysVar.SysStartHour = SysStartHour;
                OptMainPriceSysVar.SysStartMin = SysStartMin;
                OptMainPriceSysVar.SysEndHour = SysEndHour;
                OptMainPriceSysVar.SysEndMin = SysEndMin;

                OptMainPriceSysVar.OrderStartHour = OrderStartHour;
                OptMainPriceSysVar.OrderStartMin = OrderStartMin;
                OptMainPriceSysVar.OrderEndHour = OrderEndHour;
                OptMainPriceSysVar.OrderEndMin = OrderEndMin;
                OptMainPriceSysVar.SysStartState = OrderStartSignal;
                OptMainPriceSysVar.SysEndState = OrderEndSignal;

                OptMainPriceSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                OptMainPriceSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                OptMainPriceSysVar.PerLossLiquidValue = PerLossLiquidValue;
                OptMainPriceSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                OptMainPriceSysVar.AutoOrder = AutoOrder;
                OptMainPriceSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                OptMainPriceSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                OptMainPriceSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                OptMainPriceSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                OptMainPriceSysVar.PerOrderAmount = PerOrderAmount;

                OptMainPriceSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                OptMainPriceSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                OptMainPriceSysVar.StepLiquidVal = StepLiquidVal;
                OptMainPriceSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                OptMainPriceSysVar.MinProfit = MinProfit;
                OptMainPriceSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                OptMainPriceSysVar.OrderTarget = OrderTarget;
                OptMainPriceSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeOptCenterPrice)
            {
                OptCenterPriceSysVar.SysStartHour = SysStartHour;
                OptCenterPriceSysVar.SysStartMin = SysStartMin;
                OptCenterPriceSysVar.SysEndHour = SysEndHour;
                OptCenterPriceSysVar.SysEndMin = SysEndMin;

                OptCenterPriceSysVar.OrderStartHour = OrderStartHour;
                OptCenterPriceSysVar.OrderStartMin = OrderStartMin;
                OptCenterPriceSysVar.OrderEndHour = OrderEndHour;
                OptCenterPriceSysVar.OrderEndMin = OrderEndMin;
                OptCenterPriceSysVar.SysStartState = OrderStartSignal;
                OptCenterPriceSysVar.SysEndState = OrderEndSignal;

                OptCenterPriceSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                OptCenterPriceSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                OptCenterPriceSysVar.PerLossLiquidValue = PerLossLiquidValue;
                OptCenterPriceSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                OptCenterPriceSysVar.AutoOrder = AutoOrder;
                OptCenterPriceSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                OptCenterPriceSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                OptCenterPriceSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                OptCenterPriceSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                OptCenterPriceSysVar.PerOrderAmount = PerOrderAmount;

                OptCenterPriceSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                OptCenterPriceSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                OptCenterPriceSysVar.StepLiquidVal = StepLiquidVal;
                OptCenterPriceSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                OptCenterPriceSysVar.MinProfit = MinProfit;
                OptCenterPriceSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                OptCenterPriceSysVar.OrderTarget = OrderTarget;
                OptCenterPriceSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeOptBothSell)
            {
                OptBothSellSysVar.SysStartHour = SysStartHour;
                OptBothSellSysVar.SysStartMin = SysStartMin;
                OptBothSellSysVar.SysEndHour = SysEndHour;
                OptBothSellSysVar.SysEndMin = SysEndMin;

                OptBothSellSysVar.OrderStartHour = OrderStartHour;
                OptBothSellSysVar.OrderStartMin = OrderStartMin;
                OptBothSellSysVar.OrderEndHour = OrderEndHour;
                OptBothSellSysVar.OrderEndMin = OrderEndMin;
                OptBothSellSysVar.SysStartState = OrderStartSignal;
                OptBothSellSysVar.SysEndState = OrderEndSignal;

                OptBothSellSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                OptBothSellSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                OptBothSellSysVar.PerLossLiquidValue = PerLossLiquidValue;
                OptBothSellSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                OptBothSellSysVar.AutoOrder = AutoOrder;
                OptBothSellSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                OptBothSellSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                OptBothSellSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                OptBothSellSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                OptBothSellSysVar.PerOrderAmount = PerOrderAmount;

                OptBothSellSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                OptBothSellSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                OptBothSellSysVar.StepLiquidVal = StepLiquidVal;
                OptBothSellSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                OptBothSellSysVar.MinProfit = MinProfit;
                OptBothSellSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                OptBothSellSysVar.OrderTarget = OrderTarget;
                OptBothSellSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeOptBend)
            {
                OptBendSysVar.SysStartHour = SysStartHour;
                OptBendSysVar.SysStartMin = SysStartMin;
                OptBendSysVar.SysEndHour = SysEndHour;
                OptBendSysVar.SysEndMin = SysEndMin;

                OptBendSysVar.OrderStartHour = OrderStartHour;
                OptBendSysVar.OrderStartMin = OrderStartMin;
                OptBendSysVar.OrderEndHour = OrderEndHour;
                OptBendSysVar.OrderEndMin = OrderEndMin;
                OptBendSysVar.SysStartState = OrderStartSignal;
                OptBendSysVar.SysEndState = OrderEndSignal;

                OptBendSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                OptBendSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                OptBendSysVar.PerLossLiquidValue = PerLossLiquidValue;
                OptBendSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                OptBendSysVar.AutoOrder = AutoOrder;
                OptBendSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                OptBendSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                OptBendSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                OptBendSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                OptBendSysVar.PerOrderAmount = PerOrderAmount;

                OptBendSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                OptBendSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                OptBendSysVar.StepLiquidVal = StepLiquidVal;
                OptBendSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                OptBendSysVar.MinProfit = MinProfit;
                OptBendSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                OptBendSysVar.OrderTarget = OrderTarget;
                OptBendSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
            else if (a_SysType == GlobalVar.SysTypeSubject)
            {
                SubjectSysVar.SysStartHour = SysStartHour;
                SubjectSysVar.SysStartMin = SysStartMin;
                SubjectSysVar.SysEndHour = SysEndHour;
                SubjectSysVar.SysEndMin = SysEndMin;

                SubjectSysVar.OrderStartHour = OrderStartHour;
                SubjectSysVar.OrderStartMin = OrderStartMin;
                SubjectSysVar.OrderEndHour = OrderEndHour;
                SubjectSysVar.OrderEndMin = OrderEndMin;
                SubjectSysVar.SysStartState = OrderStartSignal;
                SubjectSysVar.SysEndState = OrderEndSignal;

                SubjectSysVar.TotalLossLiquidValue = TotalLossLiquidValue;
                SubjectSysVar.TotalProfitLiquidValue = TotalProfitLiquidValue;
                SubjectSysVar.PerLossLiquidValue = PerLossLiquidValue;
                SubjectSysVar.PerProfitLiquidValue = PerProfitLiquidValue;

                SubjectSysVar.AutoOrder = AutoOrder;
                SubjectSysVar.EnablePerLossLiquid = EnablePerLossLiquid;
                SubjectSysVar.EnablePerProfitLiquid = EnablePerProfitLiquid;
                SubjectSysVar.EnableTotalLossLiquid = EnableTotalLossLiquid;
                SubjectSysVar.EnableTotalProfitLiquid = EnableTotalProfitLiquid;

                SubjectSysVar.PerOrderAmount = PerOrderAmount;

                SubjectSysVar.EnableTotalProfitStepLiquid = EnableTotalProfitStepLiquid;
                SubjectSysVar.EnableProfitTrailStop = EnableProfitTrailStop;
                SubjectSysVar.StepLiquidVal = StepLiquidVal;
                SubjectSysVar.MaxProfitLiquidVal = MaxProfitLiquidVal;
                SubjectSysVar.MinProfit = MinProfit;
                SubjectSysVar.PerLiquidOrderAmount = PerLiquidOrderAmount;

                SubjectSysVar.OrderTarget = OrderTarget;
                SubjectSysVar.FirstMaxOrderAmount = FirstMaxOrderAmount;
            }
        }

        private void InitHogaSummitSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\HogaSummitSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            if (regStr == "True")
                HogaSummitSysVar.EnablePerLossLiquid = true;
            else
                HogaSummitSysVar.EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            if (regStr == "True")
                HogaSummitSysVar.EnablePerProfitLiquid = true;
            else
                HogaSummitSysVar.EnablePerProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                HogaSummitSysVar.EnterByClose = true;
            else
                HogaSummitSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                HogaSummitSysVar.LiquidByClose = true;
            else
                HogaSummitSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            HogaSummitSysVar.PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinDayAmp") as string;
            HogaSummitSysVar.MinDayAmp = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            HogaSummitSysVar.PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            HogaSummitSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            HogaSummitSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            HogaSummitSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            HogaSummitSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            HogaSummitSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            HogaSummitSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            HogaSummitSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            HogaSummitSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            HogaSummitSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            HogaSummitSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            HogaSummitSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            HogaSummitSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            HogaSummitSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaMaxMinDelta") as string;
            HogaSummitSysVar.MinTurnHogaMaxMinDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            HogaSummitSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            HogaSummitSysVar.MinTurnHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OneWayMinHoga") as string;
            HogaSummitSysVar.OneWayMinHoga = Convert.ToInt32(regStr);

            
        }


        private void InitCallPutSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\CallPutSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            if (regStr == "True")
                CallPutSquareOccSysVar.EnablePerLossLiquid = true;
            else
                CallPutSquareOccSysVar.EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            if (regStr == "True")
                CallPutSquareOccSysVar.EnablePerProfitLiquid = true;
            else
                CallPutSquareOccSysVar.EnablePerProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                CallPutSquareOccSysVar.EnterByClose = true;
            else
                CallPutSquareOccSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                CallPutSquareOccSysVar.LiquidByClose = true;
            else
                CallPutSquareOccSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            CallPutSquareOccSysVar.PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            CallPutSquareOccSysVar.PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            CallPutSquareOccSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            CallPutSquareOccSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            CallPutSquareOccSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            CallPutSquareOccSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            CallPutSquareOccSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            CallPutSquareOccSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            CallPutSquareOccSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            CallPutSquareOccSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            CallPutSquareOccSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            CallPutSquareOccSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            CallPutSquareOccSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            CallPutSquareOccSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            CallPutSquareOccSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            CallPutSquareOccSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            CallPutSquareOccSysVar.MinTurnHeight = Convert.ToDouble(regStr);
        }


        private void InitHogaSquareOccSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\HogaSquareOccSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            if (regStr == "True")
                HogaSquareOccSysVar.EnablePerLossLiquid = true;
            else
                HogaSquareOccSysVar.EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            if (regStr == "True")
                HogaSquareOccSysVar.EnablePerProfitLiquid = true;
            else
                HogaSquareOccSysVar.EnablePerProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                HogaSquareOccSysVar.EnterByClose = true;
            else
                HogaSquareOccSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                HogaSquareOccSysVar.LiquidByClose = true;
            else
                HogaSquareOccSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            HogaSquareOccSysVar.PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            HogaSquareOccSysVar.PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            HogaSquareOccSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            HogaSquareOccSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            HogaSquareOccSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            HogaSquareOccSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            HogaSquareOccSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            HogaSquareOccSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            HogaSquareOccSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            HogaSquareOccSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            HogaSquareOccSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            HogaSquareOccSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            HogaSquareOccSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            HogaSquareOccSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            HogaSquareOccSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            HogaSquareOccSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            HogaSquareOccSysVar.MinTurnHeight = Convert.ToDouble(regStr);
        }
        


        private void InitHogaSquareOccSet()
        {
            string regSubkey = "Software\\EasyTrader\\HogaSquareOccSet";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("MinSquareOcc") as string;
            GlobalVar.MinSquareOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxSquareOcc") as string;
            GlobalVar.MaxSquareOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MidSquareOcc") as string;
            GlobalVar.MidSquareOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxTimeOcc") as string;
            GlobalVar.MaxTimeOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LiquidMaxHoga") as string;
            GlobalVar.LiquidMaxHoga = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LiquidMidHoga") as string;
            GlobalVar.LiquidMidHoga = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LiquidMinHoga") as string;
            GlobalVar.LiquidMinHoga = Convert.ToInt32(regStr);
        }

        private void InitFirstSignalSet()
        {
            string regSubkey = "Software\\EasyTrader\\FirstSignalSet";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("FirstMinAngle") as string;
            GlobalVar.FirstMinAngle = Convert.ToDouble(regStr);

            regStr = rk.GetValue("FirstMinHeight") as string;
            GlobalVar.FirstMinHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("FirstMinPercent") as string;
            GlobalVar.FirstMinPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("FirstWave") as string;
            GlobalVar.FirstWave = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstHoga") as string;
            GlobalVar.FirstHoga = Convert.ToInt32(regStr);

            regStr = rk.GetValue("InvMinHogaDelta") as string;
            GlobalVar.InvMinHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("DivMinHogaDelta") as string;
            GlobalVar.DivMinHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("ByClose") as string;
            if (regStr == "True")
                GlobalVar.FirstSignalByClose = true;
            else
                GlobalVar.FirstSignalByClose = false;
        }

        private void InitHogaJisuSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\HogaJisuSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            //if (regStr == "True")
            //    JisuWaveHogaSummitSysVar.EnableLossLiquid = true;
            //else
            //    JisuWaveHogaSummitSysVar.EnableLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            //if (regStr == "True")
            //    JisuWaveHogaSummitSysVar.EnableProfitLiquid = true;
            //else
            //    JisuWaveHogaSummitSysVar.EnableProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                JisuWaveHogaSummitSysVar.EnterByClose = true;
            else
                JisuWaveHogaSummitSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                JisuWaveHogaSummitSysVar.LiquidByClose = true;
            else
                JisuWaveHogaSummitSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            //JisuWaveHogaSummitSysVar.LossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            //JisuWaveHogaSummitSysVar.ProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            JisuWaveHogaSummitSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            JisuWaveHogaSummitSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            JisuWaveHogaSummitSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            JisuWaveHogaSummitSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            JisuWaveHogaSummitSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            JisuWaveHogaSummitSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            JisuWaveHogaSummitSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            JisuWaveHogaSummitSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            JisuWaveHogaSummitSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            JisuWaveHogaSummitSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            JisuWaveHogaSummitSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            JisuWaveHogaSummitSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            JisuWaveHogaSummitSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaMaxMinDelta") as string;
            JisuWaveHogaSummitSysVar.MinTurnHogaMaxMinDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            JisuWaveHogaSummitSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            JisuWaveHogaSummitSysVar.MinTurnHeight = Convert.ToDouble(regStr);
        }

        private void InitHogaSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\HogaSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            if (regStr == "True")
                HogaWaveSysVar.EnablePerLossLiquid = true;
            else
                HogaWaveSysVar.EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            if (regStr == "True")
                HogaWaveSysVar.EnablePerProfitLiquid = true;
            else
                HogaWaveSysVar.EnablePerProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                HogaWaveSysVar.EnterByClose = true;
            else
                HogaWaveSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                HogaWaveSysVar.LiquidByClose = true;
            else
                HogaWaveSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            HogaWaveSysVar.PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            HogaWaveSysVar.PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            HogaWaveSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            HogaWaveSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            HogaWaveSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            HogaWaveSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            HogaWaveSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            HogaWaveSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            HogaWaveSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            HogaWaveSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            HogaWaveSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            HogaWaveSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            HogaWaveSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            HogaWaveSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            HogaWaveSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaMaxMinDelta") as string;
            HogaWaveSysVar.MinTurnHogaMaxMinDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            HogaWaveSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            HogaWaveSysVar.MinTurnHeight = Convert.ToDouble(regStr);
        }

        private void InitJisuSysVar()
        {
            string regSubkey = "Software\\EasyTrader\\JisuSys";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("EnableLossLiquid") as string;
            if (regStr == "True")
                JisuWaveSysVar.EnablePerLossLiquid = true;
            else
                JisuWaveSysVar.EnablePerLossLiquid = false;

            regStr = rk.GetValue("EnableProfitLiquid") as string;
            if (regStr == "True")
                JisuWaveSysVar.EnablePerProfitLiquid = true;
            else
                JisuWaveSysVar.EnablePerProfitLiquid = false;

            regStr = rk.GetValue("EnterByClose") as string;
            if (regStr == "True")
                JisuWaveSysVar.EnterByClose = true;
            else
                JisuWaveSysVar.EnterByClose = false;

            regStr = rk.GetValue("LiquidByClose") as string;
            if (regStr == "True")
                JisuWaveSysVar.LiquidByClose = true;
            else
                JisuWaveSysVar.LiquidByClose = false;

            regStr = rk.GetValue("LossLiquidValue") as string;
            JisuWaveSysVar.PerLossLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitLiquidValue") as string;
            JisuWaveSysVar.PerProfitLiquidValue = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            JisuWaveSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            JisuWaveSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            JisuWaveSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            JisuWaveSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            JisuWaveSysVar.SysStartState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            JisuWaveSysVar.SysEndState = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartHour") as string;
            JisuWaveSysVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysStartMin") as string;
            JisuWaveSysVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndHour") as string;
            JisuWaveSysVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SysEndMin") as string;
            JisuWaveSysVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PerOrderAmount") as string;
            JisuWaveSysVar.PerOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("FirstSignalType") as string;
            JisuWaveSysVar.FirstSignalType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTurnHogaDelta") as string;
            JisuWaveSysVar.MinTurnHogaDelta = Convert.ToInt32(regStr);

            regStr = rk.GetValue("LossMargin") as string;
            JisuWaveSysVar.LossMargin = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinTurnHeight") as string;
            JisuWaveSysVar.MinTurnHeight = Convert.ToDouble(regStr);
        }

        private void InitOperationGlobal()
        {
            string regSubkey = "Software\\EasyTrader\\Operation";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }
           
            string regStr = "";

            regStr = rk.GetValue("DayCloseHour") as string;
            GlobalVar.DayCloseHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("DayCloseMin") as string;
            GlobalVar.DayCloseMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("DayOpenTime") as string;
            GlobalVar.DayOpenTime = Convert.ToInt32(regStr);

            regStr = rk.GetValue("DayOpenMin") as string;
            GlobalVar.DayOpenMin = Convert.ToInt32(regStr);

            //regStr = rk.GetValue("MaxDayIndex") as string;
            GlobalVar.MaxDayIndex = GlobalVar.CalcMaxDayIndex();

            regStr = rk.GetValue("MaxNightIndex") as string;
            GlobalVar.MaxNightIndex = Convert.ToInt32(regStr);

            regStr = rk.GetValue("NightOpenTime") as string;
            GlobalVar.NightOpenTime = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OperationMode") as string;
            GlobalVar.OperationMode = Convert.ToInt32(regStr);

            regStr = rk.GetValue("ReferenceRange") as string;
            GlobalVar.ReferenceRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("PriceReferenceRange") as string;
            GlobalVar.PriceReferenceRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("HogaReferenceRange") as string;
            GlobalVar.HogaReferenceRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("RegressionType") as string;
            GlobalVar.RegressionType = regStr;

            regStr = rk.GetValue("StockCode") as string;
            GlobalVar.StockCode = regStr;

            regStr = rk.GetValue("MainTimerInterval") as string;
            GlobalVar.MainTimerInterval = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SubTimerInterval") as string;
            GlobalVar.SubTimerInterval = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SignalMethod") as string;
            GlobalVar.SignalMethod = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SubjectSelection") as string;
            GlobalVar.SubjectSelection = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SaveEveryMinute") as string;
            if (regStr == "True")
                GlobalVar.SaveEveryMinute = true;
            else
                GlobalVar.SaveEveryMinute = false;

            regStr = rk.GetValue("MaxDailyGap") as string;
            GlobalVar.MaxDailyGap = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OptionExtremeCase") as string;
            if (regStr == "True")
                GlobalVar.OptionExtremeCase = true;
            else
                GlobalVar.OptionExtremeCase = false;

            regStr = rk.GetValue("FirstSignalFilter") as string;
            if (regStr == "True")
                GlobalVar.FirstSignalFilter = true;
            else
                GlobalVar.FirstSignalFilter = false;

            regStr = rk.GetValue("AfterFirstSignalFilter") as string;
            if (regStr == "True")
                GlobalVar.AfterFirstSignalFilter = true;
            else
                GlobalVar.AfterFirstSignalFilter = false;

            regStr = rk.GetValue("EnableSound") as string;
            if (regStr == "True")
                GlobalVar.EnableSound = true;
            else
                GlobalVar.EnableSound = false;
        }

        private void InitOrderGlobal()
        {
            string regSubkey = "Software\\EasyTrader\\Order";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("AutoLossStop") as string;
            GlobalVar.AutoLossStopPrice = Convert.ToDouble(regStr);

            regStr = rk.GetValue("AutoOrder") as string;
            if (regStr == "True")
                GlobalVar.AutoOrder = true;
            else
                GlobalVar.AutoOrder = false;

            regStr = rk.GetValue("LiquidApply") as string;
            if (regStr == "True")
                GlobalVar.LiquidApply = true;
            else
                GlobalVar.LiquidApply = false;

            regStr = rk.GetValue("LiquidApplyAll") as string;
            if (regStr == "True")
                GlobalVar.LiquidApplyAll = true;
            else
                GlobalVar.LiquidApplyAll = false;

            regStr = rk.GetValue("PerLossLiquidApply") as string;
            if (regStr == "True")
                GlobalVar.PerLossLiquidApply = true;
            else
                GlobalVar.PerLossLiquidApply = false;

            regStr = rk.GetValue("PerProfitLiquidApply") as string;
            if (regStr == "True")
                GlobalVar.PerProfitLiquidApply = true;
            else
                GlobalVar.PerProfitLiquidApply = false;

            regStr = rk.GetValue("AutoOrderAmount") as string;
            GlobalVar.AutoOrderAmount = Convert.ToInt32(regStr);

            regStr = rk.GetValue("AutoProfitStop") as string;
            GlobalVar.AutoProfitStopPrice = Convert.ToDouble(regStr);

            regStr = rk.GetValue("ProfitStopAll") as string;
            GlobalVar.ProfitStopAll = Convert.ToDouble(regStr);

            regStr = rk.GetValue("LossStopAll") as string;
            GlobalVar.LossStopAll = Convert.ToDouble(regStr);

            regStr = rk.GetValue("LiquidPercent") as string;
            GlobalVar.LiquidPercent = Convert.ToDouble(regStr) / 100.0;

            regStr = rk.GetValue("LiquidMethod") as string;
            GlobalVar.LiquidMethod = Convert.ToInt32(regStr);

            regStr = rk.GetValue("Fare") as string;
            GlobalVar.Fare = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderCond") as string;
            GlobalVar.OrderCond = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderType") as string;
            GlobalVar.OrderType = Convert.ToInt32(regStr);

            regStr = rk.GetValue("Slipage") as string;
            GlobalVar.Slipage = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OrderStartHour") as string;
            GlobalVar.OrderStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartMin") as string;
            GlobalVar.OrderStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndHour") as string;
            GlobalVar.OrderEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndMin") as string;
            GlobalVar.OrderEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderStartSignal") as string;
            GlobalVar.OrderStartSignal = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OrderEndSignal") as string;
            GlobalVar.OrderEndSignal = Convert.ToInt32(regStr);
        }

        private void InitHogaSignalGlobal()
        {
            string regSubkey = "Software\\EasyTrader\\HogaSignal";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("MinHogaAngle") as string;
            GlobalVar.MinHogaAngle = Convert.ToDouble(regStr);

            regStr = rk.GetValue("BuySellBeginRefRange") as string;
            GlobalVar.BuySellBeginRefRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("BuySellRefRange") as string;
            GlobalVar.BuySellRefRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinHogaSignalHeight") as string;
            GlobalVar.MinHogaSignalHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinHogaLimit") as string;
            GlobalVar.MinHogaLimit = Convert.ToInt32(regStr);

            regStr = rk.GetValue("HogaValRefRange") as string;
            GlobalVar.HogaValRefRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinTimeOcc") as string;
            GlobalVar.MinTimeOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinSquareOcc") as string;
            GlobalVar.MinSquareOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxSquareOcc") as string;
            GlobalVar.MaxSquareOcc = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxHogaLiquidLimit") as string;
            GlobalVar.MaxHogaLiquidLimit = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinHogaLiquidLimit") as string;
            GlobalVar.MinHogaLiquidLimit = Convert.ToInt32(regStr);

            regStr = rk.GetValue("HogaSignalRefRange") as string;
            GlobalVar.HogaSignalRefRange = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinHogaSignalRegHeight") as string;
            GlobalVar.MinHogaSignalRegHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinHogaFirstMinHeight") as string;
            GlobalVar.MinHogaFirstMinHeight = Convert.ToDouble(regStr);
        }

        private void InitSignalGlobal()
        {
            string regSubkey = "Software\\EasyTrader\\Signal";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("HighLowPercent") as string;
            GlobalVar.HighLowPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinBarHeight") as string;
            GlobalVar.MinBarHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinBidAsk") as string;
            GlobalVar.MinBidAsk = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinBuySell") as string;
            GlobalVar.MinBuySell = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinDeltaBuySell") as string;
            GlobalVar.MinDeltaBuySell = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinDeltaBidsAsks") as string;
            GlobalVar.MinDeltaBidsAsks = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinPriceAngle") as string;
            GlobalVar.MinPriceAngle = Convert.ToDouble(regStr);

            regStr = rk.GetValue("PriceFullAngle") as string;
            GlobalVar.PriceFullAngle = Convert.ToDouble(regStr);

            regStr = rk.GetValue("StandardWaveHighLowPercent") as string;
            GlobalVar.StandardWaveHighLowPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinSignalPercent") as string;
            GlobalVar.MinSignalPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxSignalPercent") as string;
            GlobalVar.MaxSignalPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinFirstSignalPercent") as string;
            GlobalVar.MinFirstSignalPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("SignalWaveHeight") as string;
            GlobalVar.SignalWaveHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinSignalWaveHeight") as string;
            GlobalVar.MinSignalWaveHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinSignalHeight") as string;
            GlobalVar.MinSignalHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxDeltaBuySell") as string;
            GlobalVar.MaxDeltaBuySell = Convert.ToInt32(regStr);

            regStr = rk.GetValue("ForecastCompLen") as string;
            GlobalVar.ForecastCompLen = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxDeltaBidsAsks") as string;
            GlobalVar.MaxDeltaBidsAsks = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SignalEndHour") as string;
            GlobalVar.SignalEndHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SignalEndMin") as string;
            GlobalVar.SignalEndMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SignalStartHour") as string;
            GlobalVar.SignalStartHour = Convert.ToInt32(regStr);

            regStr = rk.GetValue("SignalStartMin") as string;
            GlobalVar.SignalStartMin = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinHighLowTransHeight") as string;
            GlobalVar.MinHighLowTransHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinCloseTransHeight") as string;
            GlobalVar.MinCloseTransHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("WaveRootLimit") as string;
            GlobalVar.WaveRootLimit = Convert.ToDouble(regStr);

            regStr = rk.GetValue("SignalTransMethod") as string;
            GlobalVar.SignalTransMethod = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinSignalInterval") as string;
            GlobalVar.MinSignalInterval = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MinDeltaBuySellEnable") as string;
            if (regStr == "True")
                GlobalVar.MinDeltaBuySellEnable = true;
            else
                GlobalVar.MinDeltaBuySellEnable = false;

            regStr = rk.GetValue("MaxDeltaBuySellEnable") as string;
            if (regStr == "True")
                GlobalVar.MaxDeltaBuySellEnable = true;
            else
                GlobalVar.MaxDeltaBuySellEnable = false;

            regStr = rk.GetValue("MinDeltaBidsAsksEnable") as string;
            if (regStr == "True")
                GlobalVar.MinDeltaBidsAsksEnable = true;
            else
                GlobalVar.MinDeltaBidsAsksEnable = false;

            regStr = rk.GetValue("MaxDeltaBidsAsksEnable") as string;
            if (regStr == "True")
                GlobalVar.MaxDeltaBidsAsksEnable = true;
            else
                GlobalVar.MaxDeltaBidsAsksEnable = false;

            regStr = rk.GetValue("MinHighLowHeight") as string;
            GlobalVar.MinHighLowHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxHighLowHeight") as string;
            GlobalVar.MaxHighLowHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinHighLowPercent") as string;
            GlobalVar.MinHighLowPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinCloseHeight") as string;
            GlobalVar.MinCloseHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxCloseHeight") as string;
            GlobalVar.MaxCloseHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinClosePercent") as string;
            GlobalVar.MinClosePercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinForeInfoHeight") as string;
            GlobalVar.MinForeInfoHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinCorrectForeInfoHeight") as string;
            GlobalVar.MinCorrectForeInfoHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MaxForeInfoHeight") as string;
            GlobalVar.MaxForeInfoHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("MinForeInfoLen") as string;
            GlobalVar.MinForeInfoLen = Convert.ToInt32(regStr);

            regStr = rk.GetValue("MaxForeInfoLen") as string;
            GlobalVar.MaxForeInfoLen = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OneWayMinPercent") as string;
            GlobalVar.OneWayMinPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("OneWayMinDivLen") as string;
            GlobalVar.OneWayMinDivLen = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OneWayMinDeltaBidAsk") as string;
            GlobalVar.OneWayMinDeltaBidAsk = Convert.ToInt32(regStr);

            regStr = rk.GetValue("OneWayMinDeltaBuySell") as string;
            GlobalVar.OneWayMinDeltaBuySell = Convert.ToInt32(regStr);

            regStr = rk.GetValue("CloseCompVal") as string;
            GlobalVar.CloseCompVal = Convert.ToDouble(regStr);

            regStr = rk.GetValue("EnableHogaSummitSignal") as string;
            if (regStr == "True")
                GlobalVar.EnableHogaSummitSignal = true;
            else
                GlobalVar.EnableHogaSummitSignal = false;

            regStr = rk.GetValue("CorrectWaveHeightLimit") as string;
            GlobalVar.CorrectWaveHeightLimit = Convert.ToDouble(regStr);

            regStr = rk.GetValue("SignalWaveHeightLimit") as string;
            GlobalVar.SignalWaveHeightLimit = Convert.ToDouble(regStr);
        }

        private void InitWaveGlobal()
        {
            string regSubkey = "Software\\EasyTrader\\Wave";
            // 서브키를 얻어온다. 없으면 null
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(regSubkey, true);
            // 없으면 서브키를 만든다.
            if (rk == null)
            {
                // 해당이름으로 서브키 생성
                rk = Registry.CurrentUser.CreateSubKey(regSubkey);
            }

            string regStr = "";

            regStr = rk.GetValue("SignalMinWaveHeight") as string;
            GlobalVar.SignalMinWaveHeight = Convert.ToDouble(regStr);

            regStr = rk.GetValue("SignalTransMinPercent") as string;
            GlobalVar.SignalTransMinPercent = Convert.ToDouble(regStr);

            regStr = rk.GetValue("WaveHeightLimit") as string;
            GlobalVar.WaveHeightLimit = Convert.ToDouble(regStr);

            regStr = rk.GetValue("WaveLenLimit") as string;
            GlobalVar.WaveLenLimit = Convert.ToInt32(regStr);
        }

        // 서버 실시간 데이터 객체들을 초기화 합니다.
        private void InitRealTimeDataObject()
        {
            
        }
       

        // 주문 객체를 초기화 합니다.
        private void InitOrderObject()
        {
            //주문 초기화
            int nRet;
            do
            {
                nRet = m_TdUtil.TradeInit(0);
            } while (nRet != 0);
        }

        private void On_SysFrmClosed(object sender, FormClosedEventArgs e)
        {
            EasyTrader.Form.FutureSystemFrm frm = (EasyTrader.Form.FutureSystemFrm)sender;
            string hashCode = frm.HashCode;
            for (int i = 0; i < m_SystemFrmList.Count; i++)
            {
                frm = m_SystemFrmList[i];
                if (frm.HashCode == hashCode)
                {
                    m_SystemFrmList.RemoveAt(i);
                    break;
                }
            }
        }

         private void MainFrm_Load(object sender, EventArgs e)
         {
             if (GlobalVar.OperationMode == GlobalVar.OperationModeNormal)
             {
                 m_SystemFrm = new EasyTrader.Form.FutureSystemFrm(m_ObjectETDataSet);
                 m_SystemFrm.HashCode = DateTime.Now.ToString().GetHashCode().ToString("x");
                 m_SystemFrm.FormClosed += new FormClosedEventHandler(On_SysFrmClosed);
                 m_SystemFrm.MdiParent = this;
                 m_SystemFrm.ETOrderManager = m_GSignalManager.ETOrderManager;
                 m_SystemFrm.TotalSignalManager = m_GSignalManager;
                 m_SystemFrm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                 m_SystemFrm.Show();
                 m_SystemFrmList.Add(m_SystemFrm);

             }
             else
             {
                 /*
                 m_SimulFrm = new EasyTrader.Form.SimulationFrm(m_ObjectETDataSet);
                 m_SimulFrm.HashCode = DateTime.Now.ToString().GetHashCode().ToString("x");
                 m_SimulFrm.MdiParent = this;
                 m_SimulFrm.EasyTraderSignalManager = m_GSignalManager;
                 m_SimulFrm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                 m_SimulFrm.Show();*/
             }

             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

             //this.LayoutMdi(MdiLayout.TileHorizontal);
             //SubTimer.Enabled = true;
             MainTimer.Enabled = true;
         }
#region TimerEventHandler

#endregion

         private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
         {
             MainTimer.Stop();
             SubTimer.Stop();
             //MainStopWatch.Stop();
             // 모든 시스템의 자동 주문을 해제해 준다.
             GlobalVar.ClearAllAutoOrder();
         }
#region SetChart Functions
        public void SetChartFutOptChartData()
         {

         }
#endregion

        private void 주간선물호가건수차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.FutureMstBuySellChartFrm frmchild = new EasyTrader.Chart.FutureMstBuySellChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 주간선물호가잔량차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.FutureMstBidsAsksChartFrm frmchild = new EasyTrader.Chart.FutureMstBidsAsksChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 코스피주체별차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.CPSvrNew7221KospiChartFrm frmchild = new EasyTrader.Chart.CPSvrNew7221KospiChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 프로그램매매차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.CPSvr8111SChartFrm frmchild = new EasyTrader.Chart.CPSvr8111SChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 옵션주체별차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.CPSvrNew7221OptionChartFrm frmchild = new EasyTrader.Chart.CPSvrNew7221OptionChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 선물주체별차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Chart.CPSvrNew7221FutureChartFrm frmchild = new EasyTrader.Chart.CPSvrNew7221FutureChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.GSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 주간선물거래량차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new FutOptVolumeChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주간선물베이시스차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutOptBasisChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주간선물미결제약정차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutOptUnsettledChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 야간선물현재가차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.CmeCurrChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주식차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.StockChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 시스템운영화면ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_SystemFrm = new EasyTrader.Form.FutureSystemFrm(m_ObjectETDataSet);
            m_SystemFrm.FormClosed += new FormClosedEventHandler(On_SysFrmClosed);
            // 마지막 신호 이벤트 핸들러 등록
            m_SystemFrm.HashCode = DateTime.Now.ToString().GetHashCode().ToString("x");
            m_SystemFrm.MdiParent = this;
            m_SystemFrm.ETOrderManager = m_OrderManager;
            m_SystemFrm.TotalSignalManager = m_GSignalManager;
            m_SystemFrm.Show();
            m_SystemFrmList.Add(m_SystemFrm);
        }

        private void 야간선물현재가차트ToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.CmeMstChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 야간선물호가건수차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.CmeMstBuySellChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 야간선물호가잔량차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.CmeMstBidsAsksChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 시뮬레이션화면ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (GlobalVar.OperationMode != GlobalVar.OperationModeSimul)
            {
                System.Windows.Forms.MessageBox.Show(GlobalVar.SimulationModeWarnMsg);
                return;
            }
            m_SimulFrm = new EasyTrader.Form.SimulationFrm(m_ObjectETDataSet);
            m_SimulFrm.HashCode = DateTime.Now.ToString().GetHashCode().ToString("x");
            m_SimulFrm.EasyTraderSignalManager = m_GSignalManager;
            m_SimulFrm.MdiParent = this;
            m_SimulFrm.Show();
        }

        private void dateTimePickerMain_ValueChanged(object sender, EventArgs e)
        {
            DateTime curTime = dateTimePickerMain.Value;
            GlobalVar.WorkDate = GlobalVar.DateToInt(curTime);
        }

        private void 주문창ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //InitOrderObject();
            // 주문관리자와 함께 주문창을 띄워준다.
            EasyTrader.Order.OrderFrm frmchild = new EasyTrader.Order.OrderFrm(m_OrderManager, m_ObjectETDataSet);
            frmchild.TotalSignalManager = m_GSignalManager;
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 야간선물일간ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.CmeDailyChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 해외차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.WorldCurChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주간선물일간ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutOptDailyChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주야간합산진폭차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutureDailyAmpChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 기준가차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutureDailyBaseChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 주간진폭차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.DayAmpChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 야간진폭차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.NightAmpChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 달러화ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FXKRWChartFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 저장ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_ObjectETDataSet.SaveTablesToXML();
            m_OrderManager.SaveOrderTables();
        }

        private void 상황판ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_DashBoard = new EasyTrader.Form.DashboardFrm();
            m_DashBoard.MdiParent = this;
            m_DashBoard.Show();
            //상황판ToolStripMenuItem.Checked = true;
        }

        // 날짜에 맞추어 XML 데이터를 불러온다.
        private void 불러오기ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DateTime curDate = dateTimePickerMain.Value;
            m_ObjectETDataSet.ReadTablesFromXML(curDate);
        }

        private void 운영설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_OperationSettingFrm = new EasyTrader.Form.OperationSettings();
            //m_OperationSettingFrm.MdiParent = this;
            m_OperationSettingFrm.Show();
        }

        private void 주문설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_OrderSettingFrm = new EasyTrader.Form.OrderSettings();
            //m_OrderSettingFrm.MdiParent = this;
            m_OrderSettingFrm.Show();
        }

        private void 신호설정ToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            m_SignalSettingFrm = new EasyTrader.Form.SignalSettings();
            //m_SignalSettingFrm.MdiParent = this;
            m_SignalSettingFrm.Show();
        }

        private void 파동설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_WaveSettingFrm = new EasyTrader.Form.WaveSettings();
            //m_WaveSettingFrm.MdiParent = this;
            m_WaveSettingFrm.Show();
        }

        private void 상황판차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_SignalChartFrm = new EasyTrader.Chart.SignalChartFrm();
            m_SignalChartFrm.MdiParent = this;
            m_SignalChartFrm.Show();
            상황판차트ToolStripMenuItem.Checked = true;
        }

        private void 신호편입대상설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.SignalSourceFrm();
            //frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 이미지로저장ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //if (m_SystemFrm != null)
            //{
            //    m_SystemFrm.SaveChartImage("시스템결과");
           //}

            string msg = "_";
            for (int i = 0; i < m_SystemFrmList.Count; i++)
            {
                EasyTrader.Form.FutureSystemFrm frm = m_SystemFrmList[i];
                if (frm != null)
                {
                    msg += frm.SysName;
                    msg += i.ToString();
                    frm.SaveChartImage(msg);
                }
            }
        }

        private void 호가신호설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.HogaSignalSettings();
            //frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 첫신호설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.FirstSigSetFrm();
            //frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 매수매도세력설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.HogaSquareOccSetFrm();
            //frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void dDEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (GlobalVar.AllDataDownloaded == false)
                return;

            System.Windows.Forms.Form frmchild = new EasyTrader.Option.DDETable(m_ObjectETDataSet);
            frmchild.Show();
        }

        private void 옵션차트ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Chart.FutureOptionChart(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        private void 마디가찾기ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (m_ObjectETDataSet != null)
            {
                m_ObjectETDataSet.FindCallPutFullCross();
            }
        }

        private void 옵션흐름표ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (GlobalVar.AllDataDownloaded == false)
                return;

            System.Windows.Forms.Form frmchild = new EasyTrader.Option.FlowTable(m_ObjectETDataSet);
            frmchild.Show();
        }

        private void 공통설정ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form frmchild = new EasyTrader.Form.SysCommonSetFrm();
            frmchild.Show();
        }

        private void 옵션시뮬레이션ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Form.OptionSimulFrm frmchild = new EasyTrader.Form.OptionSimulFrm(m_ObjectETDataSet);
            frmchild.MdiParent = this;
            frmchild.EasyTraderSignalManager = m_GSignalManager;

            frmchild.Show();
        }

        private void 옵션돌파붕괴목록ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Option.OpUpDownTargetTable frmchild = new EasyTrader.Option.OpUpDownTargetTable(m_ObjectETDataSet);
            frmchild.EasyTraderSignalManager = m_GSignalManager;
            frmchild.Show();
        }

        private void 옵션가격선택ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EasyTrader.Form.OptionValSelFrm frmchild = new EasyTrader.Form.OptionValSelFrm();
            frmchild.Show();
        }

        

     }
}
